﻿using System;
using System.Collections.Generic;
using EnvDTE;
using EnvDTE80;


namespace VsTortoiseSVN.Commands
{
    public class SolutionExplorerSelectedItemsResolve : SolutionExplorerSelectedItemsBase
    {
        public SolutionExplorerSelectedItemsResolve(DTE2 app, string id)
            : base(app, id)
        {
        }

        protected override vsCommandStatus QueryContextSensitiveStatus()
        {
            List<string> fullNames = GetFullNames();
            foreach (string fullName in fullNames)
            {
                if (SvnHelper.HasConflict(fullName))
                    return vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
            }

            return vsCommandStatus.vsCommandStatusUnsupported;
        }

        protected override vsCommandStatus QueryContextInsensitiveStatus()
        {
            return vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
        }

        public override bool Exec()
        {
            List<string> fullNames = GetFullNames();
            TortoiseProc.Resolve(fullNames);
            return true;
        }
    }
}
